# -*- encoding=utf8 -*-
"""
RedFlag-TC0000117  （拍摄进入装饰页）比例功能
切换4:3场景场景
切换9:16场景场景
多次切换比例场景
"""
__author__ = "ldm"

import sys
import os

# 获取当前脚本所在目录.py
current_dir = os.path.dirname(os.path.abspath(__file__))
# 获取上级目录.air
parent_dir = os.path.dirname(current_dir)
# 获取上级目录air
grandparent_dir = os.path.dirname(parent_dir)
# 获取和air目录平级的conf、testcase目录路径
conf_dir = os.path.join(grandparent_dir, 'conf')
testcase_dir = os.path.join(grandparent_dir, 'testcase')
# 将conf、testcase目录添加到sys.path
sys.path.append(conf_dir)
sys.path.append(testcase_dir)

from PageFunction import CameraVideoShooter
from elements import *

auto_setup(__file__)
shooter = CameraVideoShooter()

log("--------------------------------切换4:3场景--------------------------------------")
"""
拍摄视频进入装饰页
点击剪辑
点击比例
点击4:3
点击保存
点击保存
获取元素长宽比例 4:3
断言
"""

shooter.enter_photography_decoration_page()
shooter.click_element(edit_button)
sleep(2.0)
shooter.click_element(edit_proportion)
shooter.click_element(edit_proportion_4_3)
shooter.click_element(edit_proportion_confirm)
shooter.click_element(edit_save)
width_43,height_43 = shooter.get_element_size(decoration_page_video_page)
shooter.assert_compare(height_43,0.33, "ge", "断言失败，并未切换到4:3比例")
shooter.assert_compare(height_43,0.34, "le", "断言失败，并未切换到4:3比例")

log("--------------------------------切换9:16场景--------------------------------------")
"""
点击剪辑
点击比例
点击9:16
点击保存
点击保存
获取元素长宽比例 9:16
断言
"""

shooter.click_element(edit_button)
sleep(2.0)
shooter.click_element(edit_proportion)
shooter.click_element(edit_proportion_9_16)
shooter.click_element(edit_proportion_confirm)
shooter.click_element(edit_save)
width_916,height_916 = shooter.get_element_size(poco("cn.migu.video.clip.walle:id/clip_et_surface"))
shooter.assert_compare(height_916,0.80, "ge", "断言失败，并未切换到4:3比例")
shooter.assert_compare(height_916,0.81, "le", "断言失败，并未切换到4:3比例")

log("--------------------------------切换16:9场景--------------------------------------")
"""
点击剪辑
点击比例
点击16:9
点击保存
点击保存
获取元素长宽比例16:9
断言
"""

shooter.click_element(edit_button)
sleep(2.0)
shooter.click_element(edit_proportion)
shooter.click_element(edit_proportion_16_9)
shooter.click_element(edit_proportion_confirm)
shooter.click_element(edit_save)
width_169,height_169 = shooter.get_element_size(poco("cn.migu.video.clip.walle:id/clip_et_surface"))
shooter.assert_compare(height_169,0.25, "ge", "断言失败，并未切换到4:3比例")
shooter.assert_compare(height_169,0.26, "le", "断言失败，并未切换到4:3比例")

log("--------------------------------切换1:1场景--------------------------------------")
"""
点击剪辑
点击比例
点击1:1
点击保存
点击保存
获取元素长宽比例1:1
断言
"""

shooter.click_element(edit_button)
sleep(2.0)
shooter.click_element(edit_proportion)
shooter.click_element(edit_proportion_1_1)
shooter.click_element(edit_proportion_confirm)
shooter.click_element(edit_save)
width_11,height_11 = shooter.get_element_size(poco("cn.migu.video.clip.walle:id/clip_et_surface"))
shooter.assert_compare(height_11,0.45, "ge", "断言失败，并未切换到4:3比例")
shooter.assert_compare(height_11,0.46, "le", "断言失败，并未切换到4:3比例")

log("--------------------------------切换原始场景--------------------------------------")
"""
点击剪辑
点击比例
点击原始
点击保存
点击保存
获取元素长宽比例原始
断言
"""

shooter.click_element(edit_button)
sleep(2.0)
shooter.click_element(edit_proportion)
shooter.click_element(edit_proportion_original)
shooter.click_element(edit_proportion_confirm)
shooter.click_element(edit_save)
width_original,height_original = shooter.get_element_size(poco("cn.migu.video.clip.walle:id/clip_et_surface"))
shooter.assert_compare(height_original,0.80, "ge", "断言失败，并未切换到4:3比例")
shooter.assert_compare(height_original,0.81, "le", "断言失败，并未切换到4:3比例")

# 关闭应用
stop_app(UGC_package_name)



